<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTrashMessagesTable extends Migration
{
    /**
     * Run the migrations.
     *垃圾桶信息表
     *
     * @return void
     */
    public function up()
    {
        Schema::create('trash_messages', function (Blueprint $table) {
            //字段定义
            $table->increments('id');
            $table->integer('trash_id')->unsigned()->comment('垃圾点位id')->nullable();
            $table->foreign('trash_id')->references('id')->on('trash_sites')->onDelete('set null');
            $table->uuid('number')->comment('垃圾桶编号');
            $table->char('imei',15)->comment('设备唯一imei');
            $table->char('iccid',20)->comment('20 位 nb 卡号(字母和数字混合)');
            $table->char('imsi',15)->comment('15 位 imsi');
            $table->char('type',1)->comment('设备类别，1 有害垃圾，2 可回收垃圾，3 干垃圾 4 湿垃圾')->nullable();
            $table->string('bulk')->comment('垃圾桶容量体积')->nullable();
            $table->char('gps_sta',1)->comment('gps 定位状态，1 已定位，0 未定位')->default(0);
            // $table->float('lon',8,5)->unsigned()->comment('经度,保留 5 位小数');
            // $table->float('lat',8,5)->unsigned()->comment('纬度,保留 5 位小数');
            $table->point('location')->comment('经纬度')->nullable()->nullable();
            $table->integer('lac')->unsigned()->comment('小区号，用于 lbs 基站定位')->nullable();
            $table->integer('ci')->unsigned()->comment('基站号，用于 lbs 基站定位')->nullable();
            $table->string('ir_sta')->comment('红外对射状态，1 遮挡，0 未遮挡[0,0,1]')->nullable();
            $table->float('distance',5,2)->unsigned()->comment('超声波测量距离，单位米,保留 2 位小数')->nullable();
            $table->float('power_vol',6,3)->unsigned()->comment('电池电压，单位 v,保留 3 位小数')->nullable();
            $table->char('status',1)->comment('状态 1可用 2需维修 3需更换')->default(1);
            $table->string('company')->comment('所属公司')->nullable();
            $table->char('own',1)->comment('归属 0共有 1私有')->default(0);
            $table->boolean('damage')->comment('是否损坏 0是 1否')->default(1);
            $table->boolean('overflowing')->comment('是否满溢 0是 1否')->default(1);
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('trash_messages');
    }
}
